{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="level">
                                <option value="">等级</option>
                                {foreach $level as $k => $v}
                                <option value="{$k}" {if input('get.level')==$k}selected{/if}>
                                    {$v}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="address" placeholder="姓名|卡号" value="{:input('get.address')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="mobile" placeholder="用户手机号|ID" value="{:input('get.mobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="pmobile" placeholder="直推人手机号码" value="{:input('get.pmobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" lay-size="sm">
                        <thead>
                            <tr>
                                <th width="">ID</th>
                                <th width="">账号</th>
                                <th width="">等级</th>
                                <th width="">信誉</th>
                                <th width="">USDT</th>
                                <th width="">算力</th>
                                <th width="">代币</th>
                                <th width="">邀请码</th>
                                <th width="">是否实名</th>
                                <th width="">推荐人</th>
                                <th width="">直推下级</th>
                                <th width="">状态</th>
                                <th width="">收款方式</th>
                                <th width="">注册时间</th>
                                <th width="">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>{$v.id|default=''}</td>
                                <td>{$v.mobile|default=''}</td>
                                <td>{$v.level_text|default=''}</td>
                                <td>{$v.reput|default=''}</td>
                                <td><a title="查看USDT记录"
                                        onclick="data_edit('查看USDT记录','/user/moneylog?mobile={$v.mobile}&atype=1')"
                                        href="javascript:;" class="layui-btn layui-btn-green">
                                        {$v.umoney|default=''}
                                    </a>
                                    &nbsp;
                                    <button type="button" onclick="moneyedit('/user/money_edit','{$v.id}',1)"
                                        class="layui-btn layui-btn-xs">
                                        增减USDT
                                    </button>
                                </td>
                                <td>
                                    <a title="查看算力记录"
                                        onclick="data_edit('查看算力记录','/user/moneylog?mobile={$v.mobile}&atype=2')"
                                        href="javascript:;" class="layui-btn">
                                        {$v.pmoney|default=''}
                                    </a>
                                    <button type="button" onclick="moneyedit('/user/money_edit','{$v.id}',2)"
                                        class="layui-btn layui-btn-xs">
                                        增减算力
                                    </button>
                                </td>
                                <td><a title="查看代币记录"
                                        onclick="data_edit('查看代币记录','/user/moneylog?mobile={$v.mobile}&atype=3')"
                                        href="javascript:;" class="layui-btn">
                                        {$v.tmoney|default=''}
                                    </a>
                                    <button type="button" onclick="moneyedit('/user/money_edit','{$v.id}',3)"
                                        class="layui-btn layui-btn-xs">
                                        增减代币
                                    </button>
                                </td>
                                <td>{$v.code|default=''}</td>
                                <td>{if $v.auth == 2} <a title="实名"
                                        onclick="data_edit('实名','/user/userauth?mobile={$v.mobile}')"
                                        href="javascript:;" class="layui-btn">
                                        实名
                                    </a>{else}未实名{/if}</td>
                                <td> <a title="推荐人" onclick="data_edit('推荐人','/user/user?mobile={$v.pmobile}')"
                                        href="javascript:;" class="layui-btn">
                                        {$v.pmobile|default=''}
                                    </a></td>
                                <td> <a title="推荐人" onclick="data_edit('推荐人','/user/tree?mobile={$v.mobile}')"
                                        href="javascript:;" class="layui-btn">
                                        查看
                                    </a></td>
                                <td>{if $v.auth == 2}冻结{else}正常{/if}</td>
                                <td><a title="查看" onclick="data_edit('查看','/user/payment?mobile={$v.mobile}')"
                                        href="javascript:;" class="layui-btn">
                                        查看
                                    </a></td>
                                <td>{$v.created|default=''}</td>
                                <td class="td-manage">
                                    <a title="编辑" onclick="data_edit('编辑','/user/user_edit?id={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        编辑
                                    </a>
                                </td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function moneyedit(url, user_id, type) {
        layer.prompt({
            value: '0',
            title: '请写入需要修改的数量，大于0表示增加，小于0表示减少',
        }, function (value, index, elem) {
            $.post(url, { user_id: user_id, type: type, money: value }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
    function orderstr(title, url, id, status) {
        layer.confirm(title, { title: '请谨慎操作' }, function (index) {
            $.post(url, { id: id, status: status }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
</script>
{include file="public/footer"}